package cn.kgc.service.impl;

import cn.kgc.mapper.RoomMapper;
import cn.kgc.pojo.Room;
import cn.kgc.pojo.RoomType;
import cn.kgc.service.RoomService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
<<<<<<< HEAD
 * @author 李梦煊
 * @version 1.0
 * @date 2022/10/7 - 14:01
 */
@Service
public class RoomServiceImpl implements RoomService {

    @Autowired
    private RoomMapper roomMapper;

    @Override
    public List<Room> getRoomByName(Integer currentPage, Integer limit, String typeName) {
        return roomMapper.getRoomByName(currentPage, limit, typeName);
    }

    @Override
    public int getTotalCount(String typeName) {
        //总行数
        int totalCount = roomMapper.getTotalCount(typeName);
        //计算出总页数
        int totalPage = 0;
        if (totalCount % 2 == 0) {
            totalPage = totalCount;
        } else {
            //需要多加一页
            totalPage = totalCount;
        }
        return totalPage;
    }


    //新增房间
    @Override
    public int addRoom(Room room) {
        return roomMapper.addRoom(room);
    }


    //删除房间
    @Override
    public int deleRoomById(String roomId) {
        return roomMapper.deleRoomById(roomId);
    }

    //修改房间
    @Override
    public int updateRoom(Room room) {
        return roomMapper.updateRoom(room);
    }


    @Override
    public RoomType findRoomById(Integer typeId) {
        return roomMapper.findRoomById(typeId);
    }

    @Override
    public List<Room> addOrders(String typeName) {
        return roomMapper.addOrders(typeName);
    }

    @Override
    public Room findRoomByNum(int roomNum) {
        return roomMapper.findRoomByNum(roomNum);
    }
}
